package com.king.web.controller.system;

import com.king.common.core.controller.BaseController;
import com.king.common.core.domain.AjaxResult;
import com.king.common.core.domain.model.RegisterBody;
import com.king.common.core.redis.RedisCache;
import com.king.common.utils.StringUtils;
import com.king.framework.web.service.SysRegisterService;
import com.king.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 注册验证
 */
@RestController
public class SysRegisterController extends BaseController {
    @Autowired
    private ISysConfigService sysConfigService;

    @Autowired
    private SysRegisterService registerService;


    @PostMapping(value = "/register")
    public AjaxResult register(@RequestBody RegisterBody registerBody){
        if("true".equals(sysConfigService.selectConfigByKey("sys.account.registerUser"))){
            return error("当前系统没有开启注册功能！");
        }
        String msg = registerService.register(registerBody);
        return StringUtils.isEmpty(msg)?success():error();
    }


}
